package com.pactera.sz.cmb202101.utils;

import lombok.Data;

/**
 * 自定义响应结构
 *
 * @author guangming
 * @version 1.0
 * @date 2020/8/25/025 16:02
 **/
@Data
public class ResponseUtils {

    //业务响应状态
    private String status;

    //业务响应状态码
    private Integer code;

    //业务响应信息
    private String message;

    //业务响应数据
    private Object data;

    public ResponseUtils() {

    }

    public ResponseUtils(String status, ResponseEnum enums, Object data) {
        this.status = status;
        this.code = enums.getCode();
        this.message = enums.getMessage();
        this.data = data;
    }

    public ResponseUtils(String status, ResponseEnum enums) {
        this.status = status;
        this.code = enums.getCode();
        this.message = enums.getMessage();
    }

    /**
     * 成功返回响应结构
     *
     * @param enums 包含响应状态码、信息的枚举类
     * @param data  响应数据
     * @return com.pactera.sz.cmb202101.utils.ResponseUtils
     * @author guangming
     * @date 2020/8/26/026 10:01
     */
    public static ResponseUtils success(ResponseEnum enums, Object data) {
        return new ResponseUtils("success", enums, data);
    }

    /**
     * 失败返回响应结构
     *
     * @param enums 包含响应状态码、信息的枚举类
     * @return com.pactera.sz.cmb202101.utils.ResponseUtils
     * @author guangming
     * @date 2020/8/26/026 10:54
     */
    public static ResponseUtils failure(ResponseEnum enums) {
        return new ResponseUtils("failure", enums);
    }
}
